﻿using System;
using System.Collections.Generic;
using System.Linq; 
using NTTDATA.BEENChina.ResultCertification.Config;

namespace NTTDATA.BEENChina.ResultCertification.Checker.Numeric
{
   
    [Serializable]
    [VerfityAttribute(Id = "VerfityD0200", Name = "邮件地址检验", CategoryType = EnumCategoryType.数值, Model = true)]
    public class VerfityD0200 : VerfityOneResult
    {        
         

        public override bool CheckResult(List<List<string>> result, string entryCommon)
        {
            bool bresult = false;
            if (result == null)
            {
                return false;
            }

            if (entryCommon == "30" || entryCommon == "20")
            {
                return false;
            }

            foreach (List<string> rowResult in result)
            {

                foreach (string colReulst in rowResult)
                {

                    bresult = CheckMailAddress(colReulst);

                    if (bresult)
                    {
                        break;
                    }
                }

                if (bresult)
                {
                    break;
                }

            }
            
           

            if (bresult)
            {
                System.Console.WriteLine("VerfityD0200");
            }

            return bresult;
        }

        private bool CheckMailAddress( string result)
        {
            bool bresult = false;
 
            //2013-11-18 
            // add AsParallel()
            bresult = Logic.JaMailAddress.GetInstance().EmailAddress.AsParallel().Any( result.EndsWith);

            return ! bresult;
        }
    }
}
